home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8880 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: access1.digex.net!not-for-mail
  2. From: ell@access1.digex.net (Ell)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: polymorphism and style
  5. Date: 27 Feb 1996 04:37:36 GMT
  6. Organization: The Universe
  7. Message-ID: <4gu1qg$bmc@news4.digex.net>
  8. References: <4gr4ur$n13@alpha.pcix.com>
  9. NNTP-Posting-Host: access1.digex.net
  10. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  11.  
  12. ed lizewski (elizewsk@capecod.net) wrote:
  13. :   Question on polymorphism and style.
  14. : Want to call a function in a most derived class off a pointer to the base
  15. : class. The fuction does not exist in the base class.
  16. : I should:
  17. : 1)downcast ?
  18. : 2)add the function to the base class and add virtual stubs to every 
  19. :   class that does not use it ? 
  20. : 3)add it to the base class but define it like 
  21. :      foo( ..whatever..) {error_msg("virtual function not defined");}
  22. :   This way only the class that uses it would have to define it.
  23. : 4) ?
  24. :  
  25. : thanks for your time.
  26.  
  27. C++ Run-Time Type Information (RTTI) _may_ help you here.  And it may or
  28. may not be suitable in a proper OO design way.
  29.  
  30. Elliott
  31.  
  32.  
  33.